package cn.com.cym.gamezao.entity;


import cn.com.cym.gamezao.base.BaseEntity;
import cn.com.cym.gamezao.base.SearchPage;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;

import javax.persistence.*;
import java.io.Serializable;
import java.util.List;

@Getter
@Setter
@NoArgsConstructor
@Entity
@Accessors(chain = true)
@Table(name ="x_dict")
@ApiModel(description = "字典类")
public class Dict extends BaseEntity implements Serializable {

    private static final long serialVersionUID = -8463841554376560117L;

    @Column(length = 20)
    @ApiModelProperty(value = "字典代码",required = true,dataType = "String")
    private String code;

    @Column(length = 200)
    @ApiModelProperty(value = "字典名称",required = true,dataType = "String")
    private String name;

    /**
     * 子节点数据
     */
    @ApiModelProperty(value = "子节点数据",required = true,dataType = "Integer")
    private Integer childNums;

    //mappedBy 添加后 不会出现中间表
 /*   @Transient*/
   /* @OneToMany(mappedBy="dict",fetch = FetchType.EAGER)
    private List<DictItem> dictItems;*/

    /**
     * 字典数据 不做数据显示
     */
    @OneToMany(mappedBy="dict",fetch = FetchType.EAGER)
    private List<DictItem> dictItems;

    @Override
    public String toString() {
        return "Dict{" +
                "code='" + code + '\'' +
                ", name='" + name  +
                '}';
    }
}
